package com.example.demo.Demo1;


import com.example.demo.Character.Person;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RequestMapping("/Testq")
@RestController
public class Test1Controller {
    @RequestMapping("/test01")
    public String fun(){
        return "good nice";
    }

    @RequestMapping("/test02")
    public String fun1(String name){
        return "接收到的参数为："+name;
    }

    @RequestMapping("/test03")
    public String fun2(@RequestParam("username") String name){
        return "您接受到的参数为："+name;
    }

    @RequestMapping("/test04")
    public String fun4(@RequestParam("username") String name,@RequestParam("gcc") String password){
        return "您接收到的参数为："+name+"   "+password;
    }

    @RequestMapping("/test05")
    public String fun5(@RequestParam List<String> list){
        list.add("good");
        list.add("lisi");
        System.out.println(list);
        return list+"";
    }

      @RequestMapping("/test06")
    public String fun6(@RequestBody Person person){
        return person.toString();
      }

      @RequestMapping("/test07/{blogId}")  //获取参数
    public String fun7(@PathVariable Integer blogId){
        return blogId+" ";
      }

      @RequestMapping("/getCookie")
    public String fun8(@CookieValue String bite){    //浏览器设置的cookie的key的名字必须与这里的一致
        return "得到的cookie为"+bite+" ";
      }

      @RequestMapping("/getHeader")
    public String fun9(@RequestHeader("User-Agent") String useagent){
        return useagent;
      }

}
